class MultimediasController < ApplicationController  
  before_filter :logged_in? , :only => [:upload, :get_last_photo]
  session :cookie_only => false, :only => :upload_photo
  def upload_photo     
    if request.post?
      @multimedia = TempPhoto.new
      filename, filedata = params['Filename'], params['Filedata']      
      filedata.content_type = MIME::Types.type_for(filename).to_s      
      @multimedia.data = filedata      
      @multimedia.user_id = current_user.id 
      @multimedia.save     
    end
  end
  
  def get_last_photo
    @m = Multimedia.find(:first, :conditions => ["user_id = ?", current_user.id], 
                                 :order => "id desc")
    render :text => @m.id
  end
end
